﻿using MVC.Core;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddControllersWithViews();

builder.Services.AddTransient<ILogHelperService,LogHelperService>();


/* 
   [Route("")]
   [Route("home")]
   [Route("home/index")]
   public IActionResult Index()
   {
       return View();
   }

app.UseMvc();
 */

builder.Services.AddMvc(options =>
{
    options.EnableEndpointRouting = false;
    // 添加全局过滤器
    options.Filters.Add(typeof(TestActionFilter));
});


var app = builder.Build();

// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
    app.UseExceptionHandler("/Home/Error");
    // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
    app.UseHsts();
}

app.UseHttpsRedirection();
app.UseStaticFiles();

app.UseRouting();

app.UseAuthorization();

// 区域中的路由
app.MapAreaControllerRoute("manage_areas",
    "Manage",
    pattern: "manage/{controller=Home}/{action=Index}/{id?}");




app.MapControllerRoute(
    name: "space_areas",
    pattern: "space/{controller=Home}/{action=Index}/{id?}");




app.MapControllerRoute(
    name: "blog",
    pattern: "{name}",
    defaults: new {controller = "Blog", action = "Index"});

//
// app.MapControllerRoute(
//     name: "default",
//     pattern: "{controller=Home}/{action=Index}/{id?}");

app.UseMvc();

app.Run();
